All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sun.servlet.http.HttpResponse

java.lang.Object
   |
   +----sun.servlet.http.HttpResponse

public class HttpResponse
extends Object
implements HttpServletResponse, Observer
This class represents an HTTP servlet response.


Variable Index

 o bufHeader
The buffer used to set the header buffer.
 o con
The connection for this servlet.
 o contentLenSet
 o headerBytes
The response header size in bytes.
 o headers
The message headers for this response.
 o keepAlive
Set to true when keep-alive is enabled.
 o out
The output stream for writing response data.
 o outHeader
The output stream for writing headers.
 o protocol
The protocol of the response.
 o reason
The status message of the response.
 o status
The status code of the response.

Constructor Index

 o HttpResponse()
Creates a new HttpResponse object.

Method Index

 o containsHeader(String)
Returns true if the specified header field is contained in this response otherwise returns false.
 o finish()
Finishes the response.
 o getEntityBytes()
Returns the size of the entity data for this response.
 o getHeaders()
Returns the message header for this response.
 o getKeepAlive()
Returns true if this connection should be kept alive.
 o getOutputStream()
Returns an output stream for writing response data.
 o getStatus()
Returns the status code of the response.
 o getTotalBytes()
Returns the total number of bytes for this response.
 o init(ServletConnection)
Initializes this response with the specified servlet connection.
 o next()
Begins the next response.
 o reason(int)
Returns a default reason phrase for the specified status code.
 o reset()
Resets the servlet response.
 o sendError(int)
Sends an error response to the client using the specified status code and no default message.
 o sendError(int, String)
Sends an error response to the client using the specified status code and detail message.
 o sendRedirect(String)
Sends a redirect response to the client using the specified redirect location URL.
 o setContentLength(int)
Defines the content length for this response.
 o setContentType(String)
Defines the content type for this response.
 o setDateHeader(String)
Adds a date header to the current time.
 o setDateHeader(String, long)
Adds a date header with the specified time.
 o setHeader(String, String)
Adds a header field with the specified string value.
 o setIntHeader(String, int)
Adds a header field with the specified integer value.
 o setKeepAlive(boolean)
Used to indicate whether this connection should be kept alive.
 o setProtocol(String)
Sets the protocol of the response.
 o setStatus(int)
Sets the status code and a default message for this response.
 o setStatus(int, String)
Sets the status code and message for this response.
 o update(Observable, Object)
This method is called for a full request when the servlet first writes to the output stream.
 o writeHeaders()

Variables

 o status
 protected int status
The status code of the response.

 o reason
 protected String reason
The status message of the response.

 o protocol
 protected String protocol
The protocol of the response.

 o headers
 protected final MimeHeaders headers
The message headers for this response.

 o out
 protected HttpOutputStream out
The output stream for writing response data.

 o outHeader
 protected HttpOutputStream outHeader
The output stream for writing headers.

 o bufHeader
 protected ByteArrayOutputStream bufHeader
The buffer used to set the header buffer.

 o con
 protected ServletConnection con
The connection for this servlet.

 o headerBytes
 protected int headerBytes
The response header size in bytes.

 o keepAlive
 protected boolean keepAlive
Set to true when keep-alive is enabled.

 o contentLenSet
 protected boolean contentLenSet

Constructors

 o HttpResponse
 public HttpResponse()
Creates a new HttpResponse object.

Methods

 o init
 public void init(ServletConnection con) throws IOException
Initializes this response with the specified servlet connection.

Parameters:
con - the servlet connection
 o next
 public void next()
Begins the next response.

 o finish
 public void finish() throws IOException
Finishes the response.

 o reset
 public void reset()
Resets the servlet response.

 o getTotalBytes
 public int getTotalBytes()
Returns the total number of bytes for this response.

 o getEntityBytes
 public int getEntityBytes()
Returns the size of the entity data for this response.

 o setProtocol
 public void setProtocol(String protocol)
Sets the protocol of the response. Should be called immediately after initializing the response.

 o setKeepAlive
 public void setKeepAlive(boolean enable)
Used to indicate whether this connection should be kept alive.

Parameters:
enable - if true then keep connection alive
 o getKeepAlive
 public boolean getKeepAlive()
Returns true if this connection should be kept alive.

 o setContentLength
 public void setContentLength(int len)
Defines the content length for this response. This call must only be made once. Not setting the content length may cause significant performance degradation.

Parameters:
len - the content length
 o setContentType
 public void setContentType(String type)
Defines the content type for this response. This call must only be made once.

Parameters:
type - the content type
 o getOutputStream
 public ServletOutputStream getOutputStream()
Returns an output stream for writing response data.

 o setStatus
 public void setStatus(int status,
                       String reason)
Sets the status code and message for this response.

Parameters:
status - the status code
reason - the status message
 o setStatus
 public void setStatus(int status)
Sets the status code and a default message for this response.

Parameters:
status - the status code
 o getStatus
 public int getStatus()
Returns the status code of the response.

 o setHeader
 public void setHeader(String name,
                       String s)
Adds a header field with the specified string value. If this is called more than once, the current value will replace the previous value.

Parameters:
name - the header field name
s - the field's string value
 o setIntHeader
 public void setIntHeader(String name,
                          int i)
Adds a header field with the specified integer value. If this is called more than once, the current value will replace the previous value.

Parameters:
name - the header field name
i - the field's integer value
 o setDateHeader
 public void setDateHeader(String name,
                           long t)
Adds a date header with the specified time. If this is called called more than once, the current value will replace the previous value.

Parameters:
name - the header field name
t - the time in milliseconds since the epoch
 o setDateHeader
 public void setDateHeader(String name)
Adds a date header to the current time. If this is called called more than once, the current value will replace the previous value.

Parameters:
name - the header name
 o containsHeader
 public boolean containsHeader(String name)
Returns true if the specified header field is contained in this response otherwise returns false.

Parameters:
name - the header field name
 o getHeaders
 public MimeHeaders getHeaders()
Returns the message header for this response.

 o reason
 protected String reason(int status)
Returns a default reason phrase for the specified status code.

 o sendError
 public void sendError(int status,
                       String msg) throws IOException
Sends an error response to the client using the specified status code and detail message.

Parameters:
status - the status code
msg - the detail message
Throws: IOException
if an I/O error has occurred
 o sendError
 public void sendError(int status) throws IOException
Sends an error response to the client using the specified status code and no default message.

Parameters:
sc - the status code
Throws: IOException
if an I/O error has occurred
 o sendRedirect
 public void sendRedirect(String location) throws IOException
Sends a redirect response to the client using the specified redirect location URL.

Parameters:
location - the redirect location URL
Throws: IOException
if an I/O error has occurred
 o update
 public void update(Observable obs,
                    Object obj)
This method is called for a full request when the servlet first writes to the output stream. This allows the HTTP headers to be written before the response entity data.

 o writeHeaders
 protected void writeHeaders() throws IOException

All Packages  Class Hierarchy  This Package  Previous  Next  Index